<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link href="css/index2.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
</head>
<body>
<form action="add" method="post" enctype="multipart/form-data">
	<table>
		<tr>
			<td>商品名称</td><td><input type="text" name="name"> </td>
		</tr>
		<tr>
			<td>英文名称</td><td><input type="text" name="ename"> </td>
		</tr>
		<tr>
			<td>商品品牌</td><td><select id="se1" name="pid">
				<option value="">==请选择品牌==</option>
			</select> </td>
		</tr>
		<tr>
			<td>商品种类</td><td><select id="se2" name="tid">
				<option value="">==请选择种类==</option>
			</select> </td>
		</tr>
		<tr>
			<td>尺寸</td><td><input type="text" name="size"> </td>
		</tr>
		<tr>
			<td>价格</td><td><input type="text" name="price"> </td>
		</tr>
		<tr>
			<td>数量</td><td><input type="text" name="number"> </td>
		</tr>
		<tr>
			<td>标签</td><td><input type="text" name="label"> </td>
		</tr>
		<tr>
			<td>图片</td><td>
				<input type="file" name="myFile">
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<input type="submit" value="添加">
			</td>
		</tr>
	</table>
</form>

<script type="text/javascript">
	$.post(
		"selectbrand",
		{},
		function (mas) {
			var ss="";
			for ( var i in mas) {
				ss+="<option value='"+mas[i].pid+"'>"+mas[i].pname+"</option>";
			}
			$("#se1").append(ss);
		},
		"json"
	)
	
	$.post(
		"selectvariety",
		{},
		function (mas) {
			var ss="";
			for ( var i in mas) {
				ss+="<option value='"+mas[i].tid+"'>"+mas[i].tname+"</option>";
			}
			$("#se2").append(ss);
		},
		"json"
	)
	
	
	var zz="${ss}";
	if(zz!=null && zz!=''){
		if(zz){
			alert("添加成功");
			location="chengadd";
		}else{
			alert("添加失败");
		} 
	}

</script>

</body>
</html>